<template>
<div>
  <el-container >
	
    <el-header id="eee" style="background-color: #555555;">
		<el-col id="bbb" :span="12"  >
			<h1 style="color: #E9EEF3; display: inline; ">Vue—Element</h1>
			<h3 style="display: inline; padding: 3.125rem">欢迎：{{name}}</h3>
			
		  <el-dropdown trigger="click" id="www">
		    <span class="el-dropdown-link" style="color: #FFFFFF;" >
		  <el-button type="primary" plain> 管理</el-button>  <i class="el-icon-arrow-down el-icon--right"></i>
		    </span>
		    <el-dropdown-menu slot="dropdown" padding="10px">
		      <el-dropdown-item ><el-button   class="el-icon-switch-button" @click="zx()"> 注销</el-button>
		      </el-dropdown-item>
		      <el-dropdown-item >   <el-button  class="el-icon-s-operation" type="text" @click="xgmm" >修改</el-button></el-dropdown-item>
		      </el-dropdown-menu>
		  </el-dropdown>
		</el-col>
			
			 
			 <el-dialog
			               title="修改密码"
			               :visible.sync="dialogVisible"
			               width="30%">
			               <el-form :model="form" :rules="rules" ref="form">
			                 <el-form-item label="旧密码" label-width="100px" prop="oldPwd">
			                   <el-input type="password" v-model="form.oldPwd" placeholder="请输入旧密码" show-password></el-input>
			                 </el-form-item>
			                 <el-form-item label="新密码" label-width="100px" prop="newPwd" >
			                   <el-input type="password" v-model="form.newPwd" placeholder="请输入新密码" show-password></el-input>
			                 </el-form-item>
			                 <el-form-item label="密码确认" label-width="100px" prop="pwd2">
			                   <el-input type="password" v-model="form.pwd2" placeholder="请再次输入新密码" show-password></el-input>
			                 </el-form-item>
			               </el-form>
			               <span slot="footer" class="dialog-footer">
			                 <el-button @click="dialogVisible = false">取 消</el-button>
			                 <el-button type="primary" @click="changPwd">确 定</el-button>
			               </span>
			             </el-dialog>
    </el-header>
	
	
    <el-container>
      <el-aside width="200px" 　style="background-color: #ffffff; height: 93vh;"　> <el-col :span="12">

				
              <el-menu default-active="2" style="width: 199.5px;" class="el-menu-vertical-demo"
               text-color="#000000" active-text-color="#730bc8">
                <el-submenu index="1" @click="dao1" v-if="roles==='ROLE_ADMIN'">
                  <template slot="title">
                    <i class="el-icon-location"></i>
                    <span >导航1</span>
                  </template>
                  <el-menu-item-group>
                    <template slot="title"></template>
                    <el-menu-item index="1-1" @click="stusTable()">学生管理</el-menu-item>
                    <el-menu-item index="1-2" @click="teacherTable()">老师管理</el-menu-item>
					<el-menu-item index="1-2" @click="select()">部门管理</el-menu-item>
                  </el-menu-item-group>
                  <el-menu-item-group >
                    <el-menu-item index="2-1" @click="course()">课程管理</el-menu-item>
                    <el-menu-item index="2-2" @click="banji()">班级管理</el-menu-item>
                  </el-menu-item-group>

                </el-submenu>


                <el-submenu index="1" v-if="roles==='ROLE_ADMIN'||roles==='ROLE_TEACHER'">
                 <template slot="title">
                      <i class="el-icon-document"></i>
                   <span>导航2</span>
                 </template>
                  <el-menu-item-group >
                     <el-menu-item index="3-1"  @click="bjcjlr()">班级成绩录入</el-menu-item>
                     <el-menu-item index="3-2"  @click="grcjlr()">个人成绩录入</el-menu-item>
                     <el-menu-item index="3-3"  @click="cjcx()">班级成绩查询</el-menu-item>
                  </el-menu-item-group>

                </el-submenu>
                <el-submenu index="1" v-if="roles==='ROLE_STUDENT'">
                 <template slot="title">
                      <i class="el-icon-document"></i>
                   <span>导航学生</span>
                 </template>
                  
                     
                     <el-menu-item index="4-2"  @click="bjcj()">班级成绩</el-menu-item>
						<el-menu-item index="4-1"  @click="xscj()">学生成绩</el-menu-item>
                  </el-menu-item-group>

                </el-submenu>

              </el-menu>

            </el-col></el-aside>
      <el-main id="ccc"><router-view ></router-view></el-main>
    </el-container>
  </el-container>

</div>	
</template>

<script>
  export default {
    data() {
      return {
		   dialogVisible: false,
       roles:'',
	   form:{
	          oldPwd:'',
	          pwd2:'',
	          newPwd:''
	               },
	           rules:{
	                  oldPwd:[{required:true,message:'旧密码不能为空',trigger:'blur'}],
	                  newPwd:[{required:true,message:'新密码不能为空',trigger:'blur'}],
	                  pwd2:[{required:true,message:'请确认新密码',trgger:'blur'},]
	                  },
	          roles:'',
	          dialogVisible: false
      };
    },
    methods: {

      logout2() {
        this.logout();
        this.$router.replace('/');
      },
      stusTable() {

        this.$router.push('/student');
      },
      teacherTable() {

        this.$router.push('/teacherTable');
      },
      course() {
        this.$router.push('/course');
      },
      banji() {
        this.$router.push('/banji');
      },
      bjcjlr() {
        this.$router.push('/bjlrcj');
      },
      grcjlr() {
        this.$router.push('/grcjlr');
      },
      cjcx() {
        this.$router.push('/cjcx');
      },
      xscj() {
        this.$router.push('/xscj');
      },
      bjcj() {
        this.$router.push('/bjcj');
      },
	  select() {
	    this.$router.push('/select');
	  },
	   xgmm(){
	              this.dialogVisible=true
	              },
	              changPwd(){
	                this.$ajax.post('/password/save',{'password1':this.form.oldPwd,'password2':this.form.newPwd,'password3':this.form.pwd2}).then(res=>{
	                  var result=res.data
	  
	                 console.log(result)
	                 if(result.success){
	                    this.$message("修改成功，请重新登录")
	                    this.$router.replace('/')
	                 }else{
	                   this.$message(result.msg)
	                 }
	                })
	              },
      zx(){
         this.$ajax.post('logout',{}).then(res=>{
         var result=res.data;
         if(result.success){
           window.sessionStorage.removeItem("token");
           window.sessionStorage.removeItem("name");
           this.$notify.success({
             title:'提示',
             message:result.msg,
             position:'bottom-right'
           })
           this.$router.replace('/');
         }
         })
       },


    },
    created() {

      this.roles= window.sessionStorage.getItem("roles");
      this.name=window.sessionStorage.getItem("name");
       console.log("1");
      console.log(this.roles)
    }
  }
</script>

<style>
#eee{
	margin: 0;
	
}
#www{
	text-align: right;
	padding: 0.625rem;
	
	
}
#ccc{
	
	
}

body{
	background-image: url(../assets/p.jpg);
	margin: 0;
	padding: 0;
}
</style>
